codes = []

while True:
    code = input("请输入代码(以.结束)")
    if code != ".":
       codes.append(code)
    else:
       break

print(codes)

block = 0
line = 0
for i in codes:
    white = 0
    for j in i:
        if j == " ":
            white += 1
        else:
            white /= 4
            break
            
    if white == int(white):
        print(white)
        print(block)
        if white == block and block!= 0:
            codes[line] = codes[line][4:]
        if white == block +1:
            # print(line)
            codes[line] = "{" + codes[line][4:]
            block += 1
        if white == block -1:
            codes[line] = "}" + codes[line]
            block -= 1
    else:  
        print("Error")
    line += 1
print(codes)
for i in codes:
    print(i)